package objectCase;

public class Role {
    private String name;
    private int blood;


    public Role() {
    }

    public Role(String name, int blood) {
        this.name = name;
        this.blood = blood;
    }
    public void attack(Role role) {
        int hurt = (int)(Math.random() * 30 + 1);
        role.setBlood(role.getBlood() - hurt);
        //System.out.println(this.name + "攻击了" + role.getName() + "造成了" + hurt + "点伤害"+ role.getName() + "剩余血量为" + role.getBlood());
        //%s 字符串 %d 数字 占位符 \n 换行
        System.out.printf("%s攻击了%s造成了%d点伤害%s剩余血量为%d\n",this.name,role.getName(),hurt,role.getName(),role.getBlood());
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return blood
     */
    public int getBlood() {
        return blood;
    }

    /**
     * 设置
     * @param blood
     */
    public void setBlood(int blood) {
        this.blood = blood;
    }

}
